package com.atguigu.gmall.web.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.feign.product.ProductFeignClient;
import com.atguigu.gmall.model.to.CategoryTo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

/**
 * @Author 卡尼奶
 * @Date 2022/5/21 9:13
 * @Version 1.0
 */
@Controller
public class WebController {

    @Autowired
    private ProductFeignClient productFeignClient;

    @GetMapping("/")
    public String index(Model model){
        Result<List<CategoryTo>> allCategory = productFeignClient.getAllCategory();
        if (allCategory.isOk()){
            model.addAttribute("list",allCategory.getData());
        }
        return "index/index";
    }
}
